<include file="Public/sui_header" />
<link rel="stylesheet" type="text/css" href="__PUBLIC__/swipe/css/swipe.css">
<div class="addWrap" style="margin-top: 0rem;">
    <div class="swipe" id="mySwipe">
        <div class="swipe-wrap">
            <php>
                $ad = D('Ad')->select();
            </php>
            <volist name="ad" id="vo">
                <div>
                    <a href="{$vo['href']}"><img class="img-responsive" src="__PUBLIC__/file/{$vo['picture']}" /></a>
                </div>
            </volist>
        </div>
    </div>
    <ul id="position">
        <volist name="ad" id="vo">
            <li <if condition="$i eq 1"> class="cur" </if> ></li>
        </volist>
    </ul>
</div>
<script src="__PUBLIC__/swipe/js/swipe.js"></script>
<script type="text/javascript">
var bullets = document.getElementById('position').getElementsByTagName('li');
var banner = Swipe(document.getElementById('mySwipe'), {
    auto: 2000,
    continuous: true,
    disableScroll: false,
    callback: function(pos) {
        var i = bullets.length;
        while (i--) {
            bullets[i].className = ' ';
        }
        bullets[pos].className = 'cur';
    }
});
</script>
<script>
$(document).ready(function(){
	var turnplate={};
    $.post("{:U('Home/Travelgame/gamebg')}", {}, function (ret) {
            turnplate.restaraunts = ret.name;
            turnplate.colors = ["#FFF4D6", "#FFFFFF", "#FFF4D6", "#FFFFFF", "#FFF4D6", "#FFFFFF", "#FFF4D6", "#FFFFFF", "#FFF4D6", "#FFFFFF"];
            turnplate.login = "{:U('Home/User/login')}";
            turnplate.url = "{:U('Home/Travelgame/gameret')}";
            $("#dial").dial(turnplate);
    }, 'json');
});
</script>
</br>
<div class="card">
&nbsp;
<div id="dial" style="overflow-x:hidden;width:80%">
</div>
<div class="card-content">
<div class="content-block">
</div>
&nbsp;<a href="{:U('Home/Travelgame/alert', ['key' => 'prize_url'])}" style="float:right;right:2px">领奖方法>></a>
</div>
</div>
<table class="sort-table">
		<tr>
			<td>
				<a 
					<if condition="$_GET['order'] eq '' OR $_GET['order'] eq 'id'">
					href="__ACTION__/order/id desc"
					class="sort-active" 
					> 默认<i class="fa fa-sort-numeric-asc"></i>
					<elseif condition="$_GET['order'] eq 'id desc'"/>
					href="__ACTION__/order/id"
					class="sort-active" 
					> 默认<i class="fa fa-sort-numeric-desc"></i> 
					<else/>
					href="__ACTION__/order/id"
					> 默认<i class="fa fa-sort-numeric-asc"></i>
					</if>
				</a>
			</td>
              <td>
				<a 
					<if condition="$_GET['order'] eq 'funding_price desc'">
					href="__ACTION__/order/funding_price"
					class="sort-active" 
					> 价格<i class="fa fa-sort-numeric-desc"></i>
					<elseif condition="$_GET['order'] eq 'funding_price'"/>
					href="__ACTION__/order/funding_price desc"
					class="sort-active" 
					> 价格<i class="fa fa-sort-numeric-asc"></i> 
					<else/>
					href="__ACTION__/order/funding_price"
					> 价格<i class="fa fa-sort-numeric-asc"></i>
					</if>
				</a>
              </td>
              <td>
				<a 
					<if condition="$_GET['order'] eq 'vote'">
					href="__ACTION__/order/vote desc"
					class="sort-active" 
					> 投票数<i class="fa fa-sort-numeric-asc"></i>
					<elseif condition="$_GET['order'] eq 'vote desc'"/>
					href="__ACTION__/order/vote"
					class="sort-active" 
					> 投票数<i class="fa fa-sort-numeric-desc"></i> 
					<else/>
					href="__ACTION__/order/vote"
					> 投票数<i class="fa fa-sort-numeric-asc"></i>
					</if>
				</a>
			</td>

			<td align="right">
				<a href="#" class="open-panel" data-panel='#select-panel-travelgame'>筛选</a>
				<i class="fa fa-reorder"></i>
			</td>
		</tr>
	</table>
	<volist name="list" id="vo">
	    <div class="card">
	        <div class="card-header">
	            <span class="icon icon-friends"></span>
	            {$vo['name']} 
	        </div>
	        <div class="card-content">
	            <div class="card-content-inner">

	            	<div class="row">
				      <div class="col-20" style="width:30%">
	                    	<img class="list-img" src="__PUBLIC__/file/{$vo['img']}" />
				      </div>
				      <div class="col-50" style="width:60%">
				      		<php>
				      			$fundingType = D('FundingType')->find($vo['funding_type']);
				      			$fundingModel = D('Funding'.ucfirst($fundingType['en']));
				      			$fundingSpecify = $fundingModel->where(['principal_id'=>$vo['id']])->find();
				      		</php>
				      		众筹价格：￥{$vo['funding_price']} <br/>
				      		<if condition="$fundingType['en'] eq 'eat'">
				      			餐饮类型：{$fundingSpecify['eat_type']}<br/>
				      			用餐时间：{$fundingSpecify['eat_time']|date="Y-m-d H", ###}时<br/>
				      			用餐地点：{$fundingSpecify['eat_location']}<br/>
				      		<elseif condition="$fundingType['en'] eq 'hotel'"/>
				      			酒店类型：{$fundingSpecify['hotel_type']}<br/>
				      			入住时间：{$fundingSpecify['start_time']|date="Y-m-d", ###}<br/>
				      			离店时间：{$fundingSpecify['end_time']|date="Y-m-d", ###}<br/>
				      			酒店地点：{$fundingSpecify['hotel_location']}<br/>
				      		<elseif condition="$fundingType['en'] eq 'traffic'"/>
				      			交通方式：{$fundingSpecify['traffic_type']}<br/>
				      			出发地：{$fundingSpecify['departure']}<br/>
				      			目的地：{$fundingSpecify['destination']}<br/>
				      			出发时间：{$fundingSpecify['start_time']|date="Y-m-d H:i:s", ###}<br/>
				      		<elseif condition="$fundingType['en'] eq 'travel'"/>
				      			旅游类型：{$fundingSpecify['travel_type']}<br/>
				      			出发地：{$fundingSpecify['departure']}<br/>
				      			目的地：{$fundingSpecify['destination']}<br/>
				      			天数：{$fundingSpecify['days']}<br/>
							<elseif condition="$fundingType['en'] eq 'specialty'"/>
				      			旅游类型：{$fundingSpecify['specialty_type']}<br/>
				      			源产地：{$fundingSpecify['origin']}<br/>
				      			发货时间：{$fundingSpecify['delivery_time']}<br/>
							<elseif condition="$fundingType['en'] eq 'play'"/>
								娱乐类型：{$fundingSpecify['play_type']}<br/>
				      			地点：{$fundingSpecify['play_location']}<br/>
				      			时间：{$fundingSpecify['play_time']|date="Y-m-d H:i:s", ###}<br/>
				      		</if>
				      		已筹{$vo['already_num']}人/还剩{$vo['total_num'] - $vo['already_num']}人 <br/>
				      </div>
				    </div>
	                <div class="list-desc">
	                    {$vo['special']}
	                </div>
	            </div>
	        </div>
	        <div class="card-footer">
              <a id="vote_{$vo['id']}" class="button" onclick="javascript:vote({$vo['id']})" <if condition="$vo['vote'] eq 0">style="color:#686a6b;border-color:#686a6b"</if>>
              <span class="icon icon-emoji">
                <label id="vote_num_{$vo[id]}"><if condition="$vo['vote_num'] eq 0">投票<else/>{$vo['vote_num']}</if></label></span></a>

            <a id="like_{$vo['id']}" class="button" onclick="like({$vo['id']})" <if condition="$vo['like'] eq 0">style="color:#686a6b;border-color:#686a6b"</if>>
              <span class="icon icon-star">
                <label id="like_num_{$vo['id']}"><if condition="$vo['like_num'] eq 0">赞<else/>{$vo['like_num']}</if></label></span></a>

            <a href="{:U('Travelgame/detail', ['id'=>$vo['id'], 'discuss'=>1])}" class="button" <if condition="$vo['comment'] eq 0">style="color:#686a6b;border-color:#686a6b"</if>>
              <span class="icon icon-message">
              <label id="discuss_num"><if condition="$vo['comment_num'] eq 0">评论<else/>{$vo['comment_num']}</if></label></span></a>

	          <a href="{:U('Travelgame/detail', ['id'=>$vo['id']])}" class="button"><span class="icon icon-search"></span> 查看详情</a>
	        </div>
	    </div>
</volist>
{$page}
<include file="Public/sui_footer" />
<script>
function vote(id) {
    var mode = "{$mode}";
    console.log(mode);
    if (mode == 'vote') {
    $.post('{:U(vote)}', {fid: id}, function (ret) {
        if (ret.status == 0) {
            if (ret.flag == 1) {
                $("#vote_"+id).attr('style', '');
            } else {
                $("#vote_"+id).attr('style', 'color:#686a6b;border-color:#686a6b');
            }
            $("#vote_num_"+id).html(ret.num);
        } else if (ret.status == 2) {
            alert(ret.msg);
            location.href = "{:U('Home/User/login')}";
        } else {
            alert(ret.msg);
        }
    }, 'json');
    } else {
        location.href = "{:U('Home/Travelgame/alert', ['key' => 'votedetail'])}";
    }
}

function like(id) {
    $.post('{:U(like)}', {fid: id}, function (ret) {
        if (ret.status == 0) {
            if (ret.flag == 1) {
                $("#like_"+id).attr('style', '');
            } else {
                $("#like_"+id).attr('style', 'color:#686a6b;border-color:#686a6b');
            }
            $("#like_num_"+id).html(ret.num);
        } else if (ret.status == 2) {
            alert(ret.msg);
            location.href = "{:U('Home/User/login')}";
        } else {
            alert(ret.msg);
        }
    }, 'json');
}
$("#alertdetail").on('click','.alert-text',function () {
                $.alert('{$alertdetail}');
});
$("#prize_url").on('click','.alert-text',function () {
                $.alert('{$prize_url}');
});

</script>
